package com.whut.googleplay.holder;

import android.view.View;
import android.widget.ImageView;
import android.widget.RatingBar;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.whut.googleplay.R;
import com.whut.googleplay.bean.AppInfo;
import com.whut.googleplay.global.Config;
import com.whut.googleplay.http.HttpHelper;
import com.whut.googleplay.utils.StringUtils;
import com.whut.googleplay.utils.UIUtils;

/**
 * ============================================================
 * <br/>
 * 作 者 :        xyb
 * <br/>
 * 版 本 :        1.0
 * <br/>
 * 创建日期 ：     2016-04-27 下午3:45
 * <br/>
 * 描 述 ：
 * <br/>
 * 修订历史 ：
 * <br/>
 * ============================================================
 **/
public class HomePageHolder extends BaseHolder<AppInfo>{

    private ImageView item_icon;
    private TextView item_title;
    private RatingBar item_rating;
    private TextView item_size;
    private TextView item_bottom;

    @Override
    public View initView() {
        View view = UIUtils.inflate(R.layout.list_item);

        item_icon = (ImageView) view.findViewById(R.id.item_icon);

        item_title = (TextView) view.findViewById(R.id.item_title);

        item_rating = (RatingBar) view.findViewById(R.id.item_rating);

        item_size = (TextView) view.findViewById(R.id.item_size);

        item_bottom = (TextView) view.findViewById(R.id.item_bottom);

        return view;
    }

    @Override
    public void refreshView() {
        AppInfo appInfo = getData();
        item_title.setText(appInfo.getName());
        item_rating.setRating(appInfo.getStars());
        item_size.setText(StringUtils.formatFileSize(appInfo.getSize()));
        item_bottom.setText(appInfo.getDes());
        Glide.with(UIUtils.getContext()).load(Config.ROOT_URL + "image?name=" + appInfo.getIconUrl()).into(item_icon);
    }


}
